using System;
using System.Runtime.CompilerServices;
using UnityEngine;
using WorldMap.TouchCamera;
using Yoozoo.Framework.Core;

namespace WorldMapBase.LOD
{
    public class LodBehaviorManager : MonoBehaviour
    {
        [SerializeField]
        private CastleLodBehavior _castleLodBehavior;

        public static CastleLodBehavior CastleLodBehavior;
        
        
        public void Init()
        {
            CastleLodBehavior = _castleLodBehavior;
            WorldGlobalLodListener.AddLodLevelListener(OnLodLevelChanged);
            WorldGlobalLodListener.AddLodPercentListener(OnLodPercentChanged);
            
        }

        private void Update()
        {
            _castleLodBehavior.OnUpdate();
        }

        private void OnLodLevelChanged(int level, int lastLevel)
        {
            _castleLodBehavior.OnUpdateLodLevel(level,lastLevel);
            
        }
        
        private void OnLodPercentChanged(int level, float percent)
        {
            _castleLodBehavior.OnUpdateLodPercent(level, percent);
            
        }
    }
}